package jsp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;

public class CustomTagDemo extends SimpleTagSupport {
    // 标签定义的属性
    private String name;
    private String price;
    private String store;

    @Override
    public void doTag() throws JspException, IOException {
        HttpServletRequest request = (HttpServletRequest) ((PageContext) getJspContext()).getRequest();
        String ip = request.getRemoteAddr();
        JspWriter out = getJspContext().getOut();
        out.write("http://www.jellythink.com 果冻想-一个原创技术文章分享网站");
        out.write("书名：" + name);
        out.write("价格：" + price);
        out.write("书店：" + store);
        out.write("ip:" + ip);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getStore() {
        return store;
    }

    public void setStore(String store) {
        this.store = store;
    }
}
